<input type="text" name="{{name}}" style="width:250px" value="{{value}}">
<input id="select{{name}}" type="button" onclick="clickSelect(this)" value="选择">
<link rel="stylesheet" type="text/css" href="/static/css/easydialog.css" />
<script type="text/javascript" src="/static/jquip/jquip.all.min.js"></script>
<script type="text/javascript" src="/static/js/easydialog.min.js"></script>
<script type="text/javascript">
var posResult;

var prompt = function(){
	return document.getElementById(arguments[0]);
};

var btnFn = function( e ){


    var str = selectObj.attr('id');
    if (str.indexOf('set-')>0)
    {
        var reg = /set-(.*)-/;
        var index =  reg.exec(str)[1];
	    $("input[name='rideposition_set-"+index+"-longitude']").val(posResult.point.lng)
	    $("input[name='rideposition_set-"+index+"-latitude']").val(posResult.point.lat)
	    $("input[name='rideposition_set-"+index+"-address']").val(posResult.address)
    }
    else
    {
	    $("input[name='{{options.longitude_name}}']").val(posResult.point.lng)
	    $("input[name='{{options.latitude_name}}']").val(posResult.point.lat)
	    $("input[name='{{options.address_name}}']").val(posResult.address)
    }

	easyDialog.close()
	return false;
};

var selectObj;
 function clickSelect(obj){
    selectObj=$(obj)
    var str = selectObj.attr('id');
    if (str.indexOf('set-')>0)
    {
        var reg = /set-(.*)-/;
        var index =  reg.exec(str)[1];
        if (index==0)
        {
                longitude=''
                latitude=''
        }
        else
        {
                longitude=''
                latitude=''
        while (index>-1)
        {
            longitude=($("input[name='rideposition_set-"+(index-1)+"-longitude']").val());
            if (longitude!='')
            {
              latitude=($("input[name='rideposition_set-"+(index-1)+"-latitude']").val());
              break;
            }
            index--;
        }
        }


    }
    else
    {
    longitude=''
    latitude=''
    }
    data='longitude='+longitude+'&latitude='+latitude


	easyDialog.open({
		container : {
			header : '选择地点',
			content : '<iframe name="iframe_name" id="iframe_name" src="/baidu/show/?'+data+'" style="height:{{options.dialog_height}};width:{{options.dialog_width}}"></iframe>',
			yesFn : btnFn,
			noFn : true
		},
		fixed : false
	});
};
</script>